import useServer from "server";
import { useMutation, useQueryClient } from "react-query";

export const useDeleteTask = () => {
  const client = useServer();
  const queryClient = useQueryClient();

  return useMutation(
    (id: number) => {
      return client(`tasks/${id}`, { method: "DELETE" });
    },
    { onSuccess: () => queryClient.invalidateQueries("tasks") }
  );
};
